package top.codedance.iotp.iot.sdk;

import com.alibaba.fastjson.JSONObject;
import top.codedance.iotp.iot.sdk.po.slave.SlaveBaseParam;
import top.codedance.iotp.iot.sdk.po.sync.*;

public class StandandService extends AbstractService {

    public StandandService(String serverHost) {
        super(serverHost);
    }
    public StandandService(String serverHost, int requestTimeout) {
        super(serverHost, requestTimeout);
    }

    public StandandService(String serverHost, String deviceId) {
        super(serverHost, deviceId);
    }

    public StandandService(String serverHost, String deviceId, int requestTimeout) {
        super(serverHost, deviceId, requestTimeout);
    }

    public JSONObject serverInfomation(BaseParam baseParam) {
        return this.request("/server/information", JSONObject.toJSONString(baseParam));
    }

    public JSONObject getAllRegistedDeviceIds(BaseParam baseParam) {
        return this.request("/server/registed/deviceIds", JSONObject.toJSONString(baseParam));
    }

    public JSONObject addDevices(AddDeviceParam addDeviceParam) {
        return this.request("/server/device/add", JSONObject.toJSONString(addDeviceParam));
    }

    public JSONObject deleteDevices(DeleteDevicceParam deleteDevicceParam) {
        return this.request("/server/device/delete", JSONObject.toJSONString(deleteDevicceParam));
    }

    public JSONObject listDevices(BaseParam baseParam) {
        return this.request("/server/device/list", JSONObject.toJSONString(baseParam));
    }

    public JSONObject addUsers(AddUserParam addUserParam) {
        return this.request("/server/user/add", JSONObject.toJSONString(addUserParam));
    }

    public JSONObject deleteUser(DeleteUserParam deleteUserParam) {
        return this.request("/server/user/delete", JSONObject.toJSONString(deleteUserParam));
    }

    public JSONObject listUsers(BaseParam baseParam) {
        return this.request("/server/user/list", JSONObject.toJSONString(baseParam));
    }

    public JSONObject setClientVersion(SetClientVersionParam setClientVersionParam) {
        return this.request("/server/client/version/set", JSONObject.toJSONString(setClientVersionParam));
    }

    public JSONObject setClientPluginsParams(SetClientPluginsParamsParam setClientPluginsParamsParam){
        return this.request("/client/plugins/params/set", JSONObject.toJSONString(setClientPluginsParamsParam));
    }

    public JSONObject getClientPluginsParams(ClientBaseParam clientBaseParam){
        return this.request("/client/plugins/params/get", JSONObject.toJSONString(clientBaseParam));
    }

    public JSONObject execSql(ExecSqlParam execSqlParam) {
        return this.request("/client/control/query", JSONObject.toJSONString(execSqlParam));
    }

    public JSONObject execGenericDB(ExecGenericDbParam execGenericDbParam){
        return this.request("/client/generic/db/query", JSONObject.toJSONString(execGenericDbParam));
    }

    public JSONObject execMysql(ExecMysqlParam execMysqlParam){
        return this.request("/client/mysql/query", JSONObject.toJSONString(execMysqlParam));
    }

    public JSONObject execMssql(ExecMssqlParam execMssqlParam){
        return this.request("/client/mssql/query", JSONObject.toJSONString(execMssqlParam));
    }

    public JSONObject execOracle(ExecOracleParam execOracleParam){
        return this.request("/client/oracle/query", JSONObject.toJSONString(execOracleParam));
    }

    public JSONObject execCom(ExecComParam execComParam) {
        return this.request("/client/com/command", JSONObject.toJSONString(execComParam));
    }

    public JSONObject execUdp(ExecUdpParam execUdpParam) {
        return this.request("/client/udp/command", JSONObject.toJSONString(execUdpParam));
    }

    public JSONObject execOpc(ExecOpcParam execOpcParam) {
        return this.request("/client/opc/command", JSONObject.toJSONString(execOpcParam));
    }

    public JSONObject execModbus(ExecModBusParam execModBusParam) {
        return this.request("/client/modbus/command", JSONObject.toJSONString(execModBusParam));
    }

    public JSONObject execBacnet(ExecBacNetParam execBacNetParam) {
        return this.request("/client/bacnet/command", JSONObject.toJSONString(execBacNetParam));
    }

    public JSONObject ExecSystem(ExecSystemParam execSystemParam) {
        return this.request("/client/system/command", JSONObject.toJSONString(execSystemParam));
    }

    public JSONObject execHttp(ExecHttpParam execHttpParam){
        return this.request("/client/http/command", JSONObject.toJSONString(execHttpParam));
    }

    public JSONObject execPushData(ExecPushDataParam execPushDataParam){
        return this.request("/client/pushData/get", JSONObject.toJSONString(execPushDataParam));
    }

    public JSONObject shutdownClient(BaseParam baseParam){
        return this.request("/client/shutdown", JSONObject.toJSONString(baseParam));
    }

    @Override
    public JSONObject viewClientVersion(BaseParam baseParam) {
        return this.request("/client/view/version", JSONObject.toJSONString(baseParam));
    }

    @Override
    public JSONObject viewClientInfomation(BaseParam baseParam) {
        return this.request("/client/view/infomation", JSONObject.toJSONString(baseParam));
    }

    @Override
    public JSONObject registryHealthy() {
        return this.request("/healthy", noneBoby);
    }

    @Override
    public JSONObject registryInformation() {
        return this.request("/information", noneBoby);
    }

    @Override
    public JSONObject serverListOnRegistry() {
        return this.request("/query/server/list", noneBoby);
    }

    @Override
    public JSONObject opration(SlaveBaseParam slaveBaseParam) {
        return this.request("/operation", JSONObject.toJSONString(slaveBaseParam));
    }
}
